<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Models\Client;
use Faker\Generator as Faker;
use \App\Models\User;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/


$factory->define(App\Models\Client::class, function (Faker $faker) {
    $sentence = $faker->sentence();

    // 随机取 5 年前到现在的时间
    $updated_at = $faker->dateTimeBetween('-3 months');
    // 传参为生成最大时间不超过，创建时间永远比更改时间要早
    $created_at = $faker->dateTimeBetween('-3 months',$updated_at);


    // 线索
    $data['true_client'] = 2;
    $data['in_sea'] = 2;
    $data['status'] = $faker->randomNumber(2,5);
    $data['employee_id'] = array_rand(User::Users());

    return [
        'name' => $faker->name,
        'mobile' => $faker->phoneNumber,
        'sex' => $faker->randomNumber(1,2),
        'marriage' => $faker->randomNumber(1,2),
        'education' => $faker->randomNumber(1,6),
        'age' => $faker->randomNumber(18,60),
        'status' => $faker->randomNumber(1,5),

        'created_at' => $created_at,
        'updated_at' => $updated_at,
    ];
});
